<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

defined('_JEXEC') or die('Restricted access'); 
$row = $this->item;

JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'description' );
$cparams = JComponentHelper::getParams ('com_media');

JHTML::_('behavior.modal');

?>
<script language="javascript" type="text/javascript">
function submitbutton() {
	   var form = document.adminForm;
	   
	    if ( form.code.value == "" ) {
			alert("Coupon code is required");
			form.code.focus();
			return false;
		}
		 
	    if( ! checkNumber(form.count.value) ){
	        alert("Coupon count is required and must be numberic value");
	        form.count.focus();
	        return false;
	    }
	    
	    if( ! checkNumber(form.used.value) ){
	        alert("Used code number is required and must be numberic value");
	        form.used.focus();
	        return false;
	    }
	    
	    return true;
}

// Check numberic value
function checkNumber(value){    
	var numericExpression = /^[0-9]+$/;
	var numericExpression1 = /^[0-9]+\.[0-9]{1,2}$/;
	
	if ( value.match(numericExpression) || value.match(numericExpression1) )
	   return true
	else return false;
}

</script>
	
<form name="adminForm" onsubmit="return submitbutton();" action="index.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<input type="hidden" name="coupon_id" value="<?php echo $row->coupon_id; ?>" />
	<table width="100%">
	<tr>	
		<td width="80%" valign="top" align="left">
		
		    <div style="width:100%;">
				<fieldset class="adminform">
					<legend><?php echo JText::_( 'Code detail' ); ?></legend>
						<table class="admintable">
						
						<tr>
							<td class="key">
								<label for="code" width="100">
									<?php echo JText::_( 'Coupon Code' ); ?>:					
								</label>
							</td>
							<td colspan="2">
								<input class="text_area" type="text" name="code" id="code" value="<?php echo $row->code; ?>" size="50" maxlength="50" />
								<font color="Red">*</font>
							</td>
						</tr>
						
						<tr>
							<td class="key">
								<label for="count" width="100">
									<?php echo JText::_( 'Coupons Count' ); ?>:					
								</label>
							</td>
							<td colspan="2">
								<input class="text_area" type="text" name="count" id="count" value="<?php echo $row->count; ?>" size="10" maxlength="50" />
								<font color="Red">*</font>
							</td>
						</tr>
						
						<tr>
							<td class="key">
								<label for="used" width="100">
									<?php echo JText::_( 'Used' ); ?>:					
								</label>
							</td>
							<td colspan="2">
								<input class="text_area" type="text" name="used" id="used" value="<?php echo $row->used; ?>" size="10" maxlength="50" />
								<font color="Red">*</font>
							</td>
						</tr>
						<tr align="center">
    					   <td colspan="3"> </td>
    					</tr>
						<tr align="center">
    					   <td colspan="3"><input type="submit" name="button" value="<?php echo JText::_("Save");?>"/> 
    					   <input type="button" name="cancel" onclick="window.history.go(-1);" value="<?php echo JText::_("Back");?>"/></td>
    					</tr>
					</table>
				</fieldset>
			</div>
		</td>
	</tr>
	</table>
	<div class="clr"></div>	
	<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
	<input type="hidden" name="view" value="jacoupon" />
	<input type="hidden" name="layout" value="list_code" />
	<input type="hidden" name="tmpl" value="component" />
	<input type="hidden" name="task" value="save_code" />
	<?php echo JHTML::_( 'form.token' ); ?>	
</form>
<style type="text/css">
	table.admintable td.key{
		width:300px;
	}								
</style>